﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LIMS.SqlServerDAL
{
    public class LabService : LIMS.IDAL.ILab
    {
        LIMSDataContext DB = new LIMSDataContext();

        public List<LIMS.Model.Labs> FindAll()
        {
            List<LIMS.Model.Labs> labTmp = new List<Model.Labs>();
            DB.TB_lab.Select(s => s).ToList().ForEach(
                (item) =>
                {
                    Model.Labs lab = new Model.Labs()
                    {
                        ID = item.ID,
                        labID = item.labID,
                        labStatus12 = item.labStatus12,
                        labStatus34 = item.labStatus34,
                        labStatus56 = item.labStatus56,
                        labStatus78 = item.labStatus78,
                        labStatus910 = item.labStatus910,
                        labStatusDate = item.labStatusDate
                    };
                    labTmp.Add(lab);
                });
            return labTmp;
        }


        public List<LIMS.Model.Labs> FindByLabID(String labID)
        {
            List<LIMS.Model.Labs> labTmp = new List<Model.Labs>();
            DB.TB_lab.Where(w => w.labID == labID).Select(s => s).ToList().ForEach(
                (item) =>
                {
                    Model.Labs lab = new Model.Labs()
                    {
                        ID = item.ID,
                        labID = item.labID,
                        labStatus12 = item.labStatus12,
                        labStatus34 = item.labStatus34,
                        labStatus56 = item.labStatus56,
                        labStatus78 = item.labStatus78,
                        labStatus910 = item.labStatus910,
                        labStatusDate = item.labStatusDate
                    };
                    labTmp.Add(lab);
                });
            return labTmp;
        }


        public List<LIMS.Model.Labs> FindByTestDate(DateTime orderTestTime)
        {
            List<LIMS.Model.Labs> labTmp = new List<Model.Labs>();
            DB.TB_lab.Where(w => w.labStatusDate == orderTestTime).Select(s => s).ToList().ForEach(
                (item) =>
                {
                    Model.Labs lab = new Model.Labs()
                    {
                        ID = item.ID,
                        labID = item.labID,
                        labStatus12 = item.labStatus12,
                        labStatus34 = item.labStatus34,
                        labStatus56 = item.labStatus56,
                        labStatus78 = item.labStatus78,
                        labStatus910 = item.labStatus910,
                        labStatusDate = item.labStatusDate
                    };
                    labTmp.Add(lab);
                });
            return labTmp;
        }

    }

}
